<template>
  <ul>
    <li v-for="(item, index) in arr" :key="item" @click="handleDelete(index)">{{ item }}</li>
  </ul>
</template>

<script>
import { reactive } from 'vue'

export default {
  setup() {
    // !可以通过 reactive 函数把普通的数组包装成响应式的对象
    const arr = reactive(['a', 'b', 'c'])

    const handleDelete = (index) => {
      arr.splice(index, 1)
    }

    return {
      arr,
      handleDelete
    }
  }
}
</script>

<style lang="scss" scoped></style>